package com.z.sys.mapper;

import com.z.sys.model.Permission;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author zxy
 * @since 2020-10-14
 */
public interface PermissionMapper extends BaseMapper<Permission> {

    @Select("SELECT * FROM sys_permission p LEFT JOIN sys_role_permission rp on p.id=rp.permission_id LEFT JOIN sys_user_role ur on rp.role_id=ur.role_id where ur.user_id=#{userId} and p.type=0 order by parent_id,sort")
    List<Permission> selectListByUseId(@Param("userId") String userId);

    @Select("SELECT p.id FROM sys_permission p LEFT JOIN sys_role_permission rp on p.id=rp.permission_id where rp.role_id=#{roleId} ")
    List<Integer> selectCheckedId(String roleId);
}
